#pragma once

#include "CImg.h"

namespace GraphCutLib
{

	struct Vector2D;

	//template<typename T>
	//struct mvcRGB
	//{
	//      T r;
	//      T g;
	//      T b;

	//      mvcRGB(){}
	//      mvcRGB(T _r,T _g,T _b):r(_r),g(_g),b(_b){}

	//      mvcRGB<T>       operator * (const float f)
	//      {
	//              return mvcRGB<T>(r * f,g * f,b * f);
	//      }

	//      void            operator += (const mvcRGB<T>& mvc)
	//      {
	//              r += mvc.r;
	//              g += mvc.g;
	//              b += mvc.b;
	//      }
	//};

	template<typename T>
	struct ClonePixel
	{
		ClonePixel()
		{
			mvcWeight = 1.0f;
		}
		float                           mvcWeight;
		CellNode                        srcPos;
		CellNode                        desPos;
		std::vector<float>      borderWeightList;
		cimg_library::st_RGB<T>                 outRGB;
	};


	const unsigned char     MVC_EMPTY_MASK  = 0;
	const unsigned char     MVC_CLONE_MASK = 1;
	const unsigned char     MVC_BORDER_MASK = 2;

	class MVCLib
	{
	public:

		void            mvcClone(cimg_library::CImg<unsigned char>& srcImg,cimg_library::CImg<unsigned char>& descImg,CellScene& srcImgCellScene,CellScene& intersectScene,
			CellSceneBorderLink& borderLink,int orderLinkIndex,std::vector<ClonePixel<int> >&   clonePixelList,bool isCloseBorder = true);

	protected:

		float           comupteTan(const Vector2D& xPos,const Vector2D& p0,const Vector2D& p1);

		float           computeWValue(const float& tan1,const float& tan2,const Vector2D& p0,const Vector2D& p1);

	private:
	};
}